﻿using System;


namespace CodeStash.ExtesionMethods
{
    public static class TypeExtensionMethods
    {
        public static string GetControllerName(this Type source)
        {
            var typeName = source.Name;

            if (!typeName.EndsWith("Controller"))
            {
                throw new ArgumentException("Type " + source.FullName + " doesn't look like a controller type");
            }

            return typeName.Substring(0, typeName.Length - "Controller".Length);
        }
    }
}